package net.huashitong.synthetical.AddressBook.web;

import com.sirdc.modules.core.web.JsonBaseController;
import com.sirdc.modules.utils.StringUtils;
import net.huashitong.synthetical.AddressBook.entity.AddressBookUser;
import net.huashitong.synthetical.AddressBook.filter.BookFilter;
import net.huashitong.synthetical.AddressBook.service.AddressBookUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/bookUser")
public class AddressBookUserController extends JsonBaseController {
    @Override
    protected String getView(String s) {
        return null;
    }

    @Autowired
    private AddressBookUserService service;


    @ResponseBody
    @RequestMapping(value = "/queryUserByDept",method = RequestMethod.POST)
    public List<AddressBookUser> queryUserByDept(@RequestBody BookFilter filter){
        BookFilter bookFilter = new BookFilter();
        if(StringUtils.isNotBlank(filter.getDepartCode())){
            bookFilter.setDepartCode(filter.getDepartCode());
        }
        List<AddressBookUser> list = service.queryByFilter(bookFilter);
        return list;
    }
}
